package config.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import config.DAO.UserDao;
import config.DAO.Impl.UserDaoImpl;
import config.service.UserService;
import config.service.Impl.UserServiceImpl;

@Configuration
public class UserConfig {

	//单独一个bean的配置
	//<bean id="userDao" class="config.DAO.Impl.UserDaoImpl"></bean>
	@Bean
	public UserDao userDao(){
		return new UserDaoImpl();
	}
	
	//将一个bean注入另一个bean
	//<bean id="userService" class="config.service.Impl.UserServiceImpl">
	//	<property name="userDao" ref="userDao"/>
	//</bean>
	@Bean
	public UserService userService(){
		UserServiceImpl userService = new UserServiceImpl();
		userService.setUserDao(userDao());
		return userService;
	}
}
